package locations.actions;

import java.util.ArrayList;
import java.util.List;

import locations.dao.DAOFactory;
import locations.dao.InstitutionResponsibleDAO;
import locations.dao.InstitutionTypeDAO;
import locations.model.Institution;
import locations.model.InstitutionResponsible;
import locations.model.InstitutionType;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;


public class NewInstitutionAction extends ActionSupport implements ModelDriven<Institution> {
	
	private static final long serialVersionUID = -8124967730231198191L;
	
	private Institution institution = new Institution();
	private List<InstitutionResponsible> institutionResponsibles = new ArrayList<InstitutionResponsible>();
	private List<InstitutionType> institutionTypes = new ArrayList<InstitutionType>();
	
	public String execute(){
		
		
		InstitutionResponsibleDAO dao = DAOFactory.getInstitutionResponsibleDAO();
		this.setInstitutionResponsibles(dao.retrieveAll());
		
		InstitutionTypeDAO dao2 = DAOFactory.getInstitutionTypeDAO();
		this.setInstitutionTypes(dao2.retrieveAll());
		
		return SUCCESS;
	}
	
	
	
	public List<InstitutionType> getInstitutionTypes() {
		return institutionTypes;
	}



	public void setInstitutionTypes(List<InstitutionType> institutionTypes) {
		this.institutionTypes = institutionTypes;
	}



	public List<InstitutionResponsible> getInstitutionResponsibles() {
		return institutionResponsibles;
	}



	public void setInstitutionResponsibles(
			List<InstitutionResponsible> institutionResponsibles) {
		this.institutionResponsibles = institutionResponsibles;
	}


	public Institution getInstitution() {
		return institution;
	}



	public void setInstitution(Institution institution) {
		this.institution = institution;
	}



	@Override
	public Institution getModel() {
		return this.institution;
	}

}
